package com.zhanglu.fun.services.website.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Slf4j
@Configuration
public class ScheduleConfig {

    @Bean
    public TaskScheduler taskScheduler() {
        ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
        int cpuCores = Runtime.getRuntime().availableProcessors();
        log.info("**********CPU core size = {} **********", cpuCores);
        taskScheduler.setPoolSize(cpuCores);
        return taskScheduler;
    }
}
